package org.mxp.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * 拦截器，放行静态资源
 */
@Configuration
public class SpringMvcSupport extends WebMvcConfigurationSupport {
    // 设置静态资源访问过滤，当前类需要设置为配置类，并被扫描加载。即：静态资源直接走tomcat，不再经过SpringMVC
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 当访问/static/xxx的时候，从/pages目录下查找内容
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/js/**").addResourceLocations("classpath:/js/");
    }
}